package com.xtecher.app.base;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.xtecher.app.utils.DialogUtil;
import com.xtecher.app.utils.ToastUtil;

/**
 * Created by \(^o^)/~ on 2016/6/30.
 */
public abstract class BaseFragment extends Fragment {

    protected boolean isVisible;
    public boolean isRefresh = true;
    public boolean loading = false;
    public View footerView;
    public TextView tvMes;
    public int pageNo = 0;
    public ProgressBar progressBar;

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    public void showLoading(String msg) {
        DialogUtil.showProgress(getActivity(), TextUtils.isEmpty(msg) ? "加载中" : msg, true);
    }

    public void hideLoading() {
        DialogUtil.closeProgress();
    }

    public void showMessage(String msg) {
        if (!TextUtils.isEmpty(msg))
            ToastUtil.showShort(getContext(), msg);
    }

    public Context getContext() {
        return getActivity();
    }

    public boolean isActive() {
        return isAdded();
    }

    public void onError(String erroeMessage) {

    }
}
